13. Short Message Service (SMS) Commands > 13.8 AT+CMGW   Write Short Messages to Memory

13.8
AT+CMGW   Write Short Messages to Memory
The execute and write commands transmit a short message (either SMS-DELIVER or SMS-SUBMIT) from TE to memory storage <mem2>. Memory location <index> of the stored message is returned. Message status will be set to 'stored unsent' unless otherwise given in parameter <stat>.
After invoking the execute or write command wait for the prompt ">" and then start to write the message. To save the message simply enter <CTRL-Z>. After the prompt a timer will be started to observe the input.
To abort writing use <ESC>. Abortion is acknowledged with "OK", though the message will not be saved.
Syntax
Test Command  
Response(s)
Exec Command  
Response(s)
<CR> Text can be entered. <CTRL-Z>/<ESC>
Write Command  
AT+CMGW=<oa>/<da>[, [<tooa>/<toda>][, <stat>]]<CR> Text can be entered. <CTRL-Z>/<ESC>
Response(s)
Write Command  
AT+CMGW=<length>[, <stat>]<CR> PDU can be entered. <CTRL-Z>/<ESC>
Response(s)
Reference(s) 
PIN 
ASC0 
ASC1 
USB 
MUX1 
MUX2 
MUX3 
Charge 
Last 
GSM 07.05

Notes
•
If writing fails, for example, if a message is too long, the result code depends on the current setting of the AT^SM20 command:
If the AT^SM20 <CmgwMode>=1 (factory default) any failure to send a message is responded with "OK". Users should be aware, that despite the "OK" response, the message will not be written to the selected SMS stor­age.
If the AT^SM20 <CmgwMode> equals 0 any failure to write a message is responded with "ERROR".
 
•
If writing fails due to timeout, then
AT^SM20 <CmgwMode>=1 causes "+CMS ERROR: Unknown error" to be returned;
AT^SM20 <CmgwMode>=0 causes "+CMS ERROR: timer expired" to be returned.
•
•
For baudrates lower than 19200 it is recommended to use the line termination character only (refer to ATS3= <n>, default <CR>) before entering the text or PDU. Use of the line termination character followed by the response formating character (see ATS4= <n>, default <LF>) may cause problems.
•
•
All characters entered behind the ">" prompt will be recognized as GSM characters. For example, "Back­space" (ASCII character 8) does not delete a character, but will be inserted into the short message as an addi­tional physical character. As a result, the character you wanted to delete still appears in the text, plus the GSM code equivalent of the Backspace key.
•
Message Length in Text Mode
The maximum length of a short message depends on the used coding scheme: It is 160 characters if the 7 bit GSM coding scheme is used, and 140 characters according to the 8 bit GSM coding scheme.
In case UCS2 character set selected it is highly recommended to set Data Coding Scheme (<dcs> of AT+CSMP) to 16-bit data, otherwise the length of sms user data is restricted to 88 octets. Even better for mes­sages with UCS2 character set is the PDU Mode.
•